package com.dnjn.happiness.survey.api.factory;

import com.dnjn.happiness.common.core.domain.R;
import com.dnjn.happiness.survey.api.RemoteSurveyService;
import com.dnjn.happiness.survey.api.model.StatisticalAnalysisModel;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public class RemoteSurveyFallbackFactory implements FallbackFactory<RemoteSurveyService> {

    private static final Logger log = LoggerFactory.getLogger(RemoteSurveyFallbackFactory.class);

    @Override
    public RemoteSurveyService create(Throwable throwable) {
        log.error("调用问卷服务失败：" + throwable);
        return new RemoteSurveyService() {
            @Override
            public R<List<StatisticalAnalysisModel>> selectStatisticalAnalysisSurvryList(StatisticalAnalysisModel vo, String source) {
                return R.fail("查询问卷信息失败：{}" + throwable.getMessage());
            }
        };
    }
}
